<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="角色码" prop="roleCode">
        <el-input
          v-model="queryParams.roleCode"
          placeholder="请输入角色码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用户名" prop="userName">
        <el-input
          v-model="queryParams.userName"
          placeholder="请输入用户名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="密码" prop="password">
        <el-input
          v-model="queryParams.password"
          placeholder="请输入密码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="昵称" prop="title">
        <el-input
          v-model="queryParams.title"
          placeholder="请输入昵称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="上级用户" prop="parentId">
        <el-input
          v-model="queryParams.parentId"
          placeholder="请输入上级用户"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="sms余额" prop="smsBalance">
        <el-input
          v-model="queryParams.smsBalance"
          placeholder="请输入sms余额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="rcs余额" prop="rcsBalance">
        <el-input
          v-model="queryParams.rcsBalance"
          placeholder="请输入rcs余额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="vacant余额" prop="vacantBalance">
        <el-input
          v-model="queryParams.vacantBalance"
          placeholder="请输入vacant余额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="csp余额" prop="cspBalance">
        <el-input
          v-model="queryParams.cspBalance"
          placeholder="请输入csp余额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="ident余额" prop="identBalance">
        <el-input
          v-model="queryParams.identBalance"
          placeholder="请输入ident余额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="gsm余额" prop="gsmBalance">
        <el-input
          v-model="queryParams.gsmBalance"
          placeholder="请输入gsm余额"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="代理id" prop="agentId">
        <el-input
          v-model="queryParams.agentId"
          placeholder="请输入代理id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="修改时间" prop="changeTime">
        <el-date-picker clearable
          v-model="queryParams.changeTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择修改时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="http授权" prop="isEnableHttp">
        <el-select v-model="queryParams.isEnableHttp" placeholder="请选择http授权" clearable>
          <el-option
            v-for="dict in dict.type.sys_normal_disable"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="cmpp授权" prop="isEnableCmpp">
        <el-input
          v-model="queryParams.isEnableCmpp"
          placeholder="请输入cmpp授权"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="rcs授权" prop="isEnableRcs">
        <el-input
          v-model="queryParams.isEnableRcs"
          placeholder="请输入rcs授权"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="voids授权" prop="isEnableVoids">
        <el-input
          v-model="queryParams.isEnableVoids"
          placeholder="请输入voids授权"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="短链授权" prop="isEnableUrlshort">
        <el-input
          v-model="queryParams.isEnableUrlshort"
          placeholder="请输入短链授权"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="fence授权" prop="isEnableFence">
        <el-input
          v-model="queryParams.isEnableFence"
          placeholder="请输入fence授权"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="csp授权" prop="isEnableCsp">
        <el-input
          v-model="queryParams.isEnableCsp"
          placeholder="请输入csp授权"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="ident授权" prop="isEnableIdent">
        <el-input
          v-model="queryParams.isEnableIdent"
          placeholder="请输入ident授权"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="smpp授权" prop="isEnableSmpp">
        <el-input
          v-model="queryParams.isEnableSmpp"
          placeholder="请输入smpp授权"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="联系人" prop="contactName">
        <el-input
          v-model="queryParams.contactName"
          placeholder="请输入联系人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="联系电话" prop="contactPhone">
        <el-input
          v-model="queryParams.contactPhone"
          placeholder="请输入联系电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="联系地址" prop="contactAddress">
        <el-input
          v-model="queryParams.contactAddress"
          placeholder="请输入联系地址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="安全电话" prop="securityPhone">
        <el-input
          v-model="queryParams.securityPhone"
          placeholder="请输入安全电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="${comment}" prop="verifiedStep">
        <el-input
          v-model="queryParams.verifiedStep"
          placeholder="请输入${comment}"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="${comment}" prop="lastSendTime">
        <el-date-picker clearable
          v-model="queryParams.lastSendTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择${comment}">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="${comment}" prop="isShowSaleman">
        <el-input
          v-model="queryParams.isShowSaleman"
          placeholder="请输入${comment}"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="${comment}" prop="isLoginCaptcha">
        <el-input
          v-model="queryParams.isLoginCaptcha"
          placeholder="请输入${comment}"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="${comment}" prop="isVerifiedLimit">
        <el-input
          v-model="queryParams.isVerifiedLimit"
          placeholder="请输入${comment}"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="${comment}" prop="isWarnBalance">
        <el-input
          v-model="queryParams.isWarnBalance"
          placeholder="请输入${comment}"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="${comment}" prop="warnSilenceDays">
        <el-input
          v-model="queryParams.warnSilenceDays"
          placeholder="请输入${comment}"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="${comment}" prop="warnMinBalances">
        <el-input
          v-model="queryParams.warnMinBalances"
          placeholder="请输入${comment}"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="${comment}" prop="isMarkStar">
        <el-input
          v-model="queryParams.isMarkStar"
          placeholder="请输入${comment}"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="${comment}" prop="hidePhoneMode">
        <el-input
          v-model="queryParams.hidePhoneMode"
          placeholder="请输入${comment}"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="${comment}" prop="isAutoWhiltelist">
        <el-input
          v-model="queryParams.isAutoWhiltelist"
          placeholder="请输入${comment}"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="${comment}" prop="surlShowDetail">
        <el-input
          v-model="queryParams.surlShowDetail"
          placeholder="请输入${comment}"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="${comment}" prop="supportInterphone">
        <el-input
          v-model="queryParams.supportInterphone"
          placeholder="请输入${comment}"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="${comment}" prop="lastLoginTime">
        <el-date-picker clearable
          v-model="queryParams.lastLoginTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="请选择${comment}">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:member:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:member:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:member:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:member:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="memberList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="id" align="center" prop="id" />
      <el-table-column label="角色码" align="center" prop="roleCode" />
      <el-table-column label="用户名" align="center" prop="userName" />
      <el-table-column label="密码" align="center" prop="password" />
      <el-table-column label="昵称" align="center" prop="title" />
      <el-table-column label="上级用户" align="center" prop="parentId" />
      <el-table-column label="sms余额" align="center" prop="smsBalance" />
      <el-table-column label="rcs余额" align="center" prop="rcsBalance" />
      <el-table-column label="vacant余额" align="center" prop="vacantBalance" />
      <el-table-column label="csp余额" align="center" prop="cspBalance" />
      <el-table-column label="ident余额" align="center" prop="identBalance" />
      <el-table-column label="gsm余额" align="center" prop="gsmBalance" />
      <el-table-column label="代理id" align="center" prop="agentId" />
      <el-table-column label="修改时间" align="center" prop="changeTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.changeTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="服务备注" align="center" prop="serviceRemark" />
      <el-table-column label="http授权" align="center" prop="isEnableHttp">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.isEnableHttp"/>
        </template>
      </el-table-column>
      <el-table-column label="cmpp授权" align="center" prop="isEnableCmpp" />
      <el-table-column label="rcs授权" align="center" prop="isEnableRcs" />
      <el-table-column label="voids授权" align="center" prop="isEnableVoids" />
      <el-table-column label="短链授权" align="center" prop="isEnableUrlshort" />
      <el-table-column label="fence授权" align="center" prop="isEnableFence" />
      <el-table-column label="csp授权" align="center" prop="isEnableCsp" />
      <el-table-column label="ident授权" align="center" prop="isEnableIdent" />
      <el-table-column label="smpp授权" align="center" prop="isEnableSmpp" />
      <el-table-column label="联系人" align="center" prop="contactName" />
      <el-table-column label="联系电话" align="center" prop="contactPhone" />
      <el-table-column label="联系地址" align="center" prop="contactAddress" />
      <el-table-column label="安全电话" align="center" prop="securityPhone" />
      <el-table-column label="${comment}" align="center" prop="verifiedStep" />
      <el-table-column label="${comment}" align="center" prop="lastSendTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.lastSendTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="${comment}" align="center" prop="isShowSaleman" />
      <el-table-column label="${comment}" align="center" prop="isLoginCaptcha" />
      <el-table-column label="${comment}" align="center" prop="isVerifiedLimit" />
      <el-table-column label="${comment}" align="center" prop="isWarnBalance" />
      <el-table-column label="${comment}" align="center" prop="warnSilenceDays" />
      <el-table-column label="${comment}" align="center" prop="warnMinBalances" />
      <el-table-column label="${comment}" align="center" prop="isMarkStar" />
      <el-table-column label="${comment}" align="center" prop="hidePhoneMode" />
      <el-table-column label="${comment}" align="center" prop="isAutoWhiltelist" />
      <el-table-column label="${comment}" align="center" prop="surlDomianIds" />
      <el-table-column label="${comment}" align="center" prop="surlShowDetail" />
      <el-table-column label="${comment}" align="center" prop="supportInterphone" />
      <el-table-column label="${comment}" align="center" prop="status" />
      <el-table-column label="${comment}" align="center" prop="recordStatus" />
      <el-table-column label="${comment}" align="center" prop="loginLimitIps" />
      <el-table-column label="${comment}" align="center" prop="lastLoginTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.lastLoginTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:member:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:member:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改用户对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="角色码" prop="roleCode">
          <el-input v-model="form.roleCode" placeholder="请输入角色码" />
        </el-form-item>
        <el-form-item label="用户名" prop="userName">
          <el-input v-model="form.userName" placeholder="请输入用户名" />
        </el-form-item>
        <el-form-item label="密码" prop="password">
          <el-input v-model="form.password" placeholder="请输入密码" />
        </el-form-item>
        <el-form-item label="昵称" prop="title">
          <el-input v-model="form.title" placeholder="请输入昵称" />
        </el-form-item>
        <el-form-item label="上级用户" prop="parentId">
          <el-input v-model="form.parentId" placeholder="请输入上级用户" />
        </el-form-item>
        <el-form-item label="sms余额" prop="smsBalance">
          <el-input v-model="form.smsBalance" placeholder="请输入sms余额" />
        </el-form-item>
        <el-form-item label="rcs余额" prop="rcsBalance">
          <el-input v-model="form.rcsBalance" placeholder="请输入rcs余额" />
        </el-form-item>
        <el-form-item label="vacant余额" prop="vacantBalance">
          <el-input v-model="form.vacantBalance" placeholder="请输入vacant余额" />
        </el-form-item>
        <el-form-item label="csp余额" prop="cspBalance">
          <el-input v-model="form.cspBalance" placeholder="请输入csp余额" />
        </el-form-item>
        <el-form-item label="ident余额" prop="identBalance">
          <el-input v-model="form.identBalance" placeholder="请输入ident余额" />
        </el-form-item>
        <el-form-item label="gsm余额" prop="gsmBalance">
          <el-input v-model="form.gsmBalance" placeholder="请输入gsm余额" />
        </el-form-item>
        <el-form-item label="代理id" prop="agentId">
          <el-input v-model="form.agentId" placeholder="请输入代理id" />
        </el-form-item>
        <el-form-item label="修改时间" prop="changeTime">
          <el-date-picker clearable
            v-model="form.changeTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择修改时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="服务备注" prop="serviceRemark">
          <el-input v-model="form.serviceRemark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="http授权" prop="isEnableHttp">
          <el-radio-group v-model="form.isEnableHttp">
            <el-radio
              v-for="dict in dict.type.sys_normal_disable"
              :key="dict.value"
              :label="parseInt(dict.value)"
            >{{dict.label}}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="cmpp授权" prop="isEnableCmpp">
          <el-input v-model="form.isEnableCmpp" placeholder="请输入cmpp授权" />
        </el-form-item>
        <el-form-item label="rcs授权" prop="isEnableRcs">
          <el-input v-model="form.isEnableRcs" placeholder="请输入rcs授权" />
        </el-form-item>
        <el-form-item label="voids授权" prop="isEnableVoids">
          <el-input v-model="form.isEnableVoids" placeholder="请输入voids授权" />
        </el-form-item>
        <el-form-item label="短链授权" prop="isEnableUrlshort">
          <el-input v-model="form.isEnableUrlshort" placeholder="请输入短链授权" />
        </el-form-item>
        <el-form-item label="fence授权" prop="isEnableFence">
          <el-input v-model="form.isEnableFence" placeholder="请输入fence授权" />
        </el-form-item>
        <el-form-item label="csp授权" prop="isEnableCsp">
          <el-input v-model="form.isEnableCsp" placeholder="请输入csp授权" />
        </el-form-item>
        <el-form-item label="ident授权" prop="isEnableIdent">
          <el-input v-model="form.isEnableIdent" placeholder="请输入ident授权" />
        </el-form-item>
        <el-form-item label="smpp授权" prop="isEnableSmpp">
          <el-input v-model="form.isEnableSmpp" placeholder="请输入smpp授权" />
        </el-form-item>
        <el-form-item label="联系人" prop="contactName">
          <el-input v-model="form.contactName" placeholder="请输入联系人" />
        </el-form-item>
        <el-form-item label="联系电话" prop="contactPhone">
          <el-input v-model="form.contactPhone" placeholder="请输入联系电话" />
        </el-form-item>
        <el-form-item label="联系地址" prop="contactAddress">
          <el-input v-model="form.contactAddress" placeholder="请输入联系地址" />
        </el-form-item>
        <el-form-item label="安全电话" prop="securityPhone">
          <el-input v-model="form.securityPhone" placeholder="请输入安全电话" />
        </el-form-item>
        <el-form-item label="${comment}" prop="verifiedStep">
          <el-input v-model="form.verifiedStep" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="lastSendTime">
          <el-date-picker clearable
            v-model="form.lastSendTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择${comment}">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="${comment}" prop="isShowSaleman">
          <el-input v-model="form.isShowSaleman" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="isLoginCaptcha">
          <el-input v-model="form.isLoginCaptcha" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="isVerifiedLimit">
          <el-input v-model="form.isVerifiedLimit" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="isWarnBalance">
          <el-input v-model="form.isWarnBalance" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="warnSilenceDays">
          <el-input v-model="form.warnSilenceDays" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="warnMinBalances">
          <el-input v-model="form.warnMinBalances" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="isMarkStar">
          <el-input v-model="form.isMarkStar" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="hidePhoneMode">
          <el-input v-model="form.hidePhoneMode" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="isAutoWhiltelist">
          <el-input v-model="form.isAutoWhiltelist" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="surlDomianIds">
          <el-input v-model="form.surlDomianIds" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="${comment}" prop="surlShowDetail">
          <el-input v-model="form.surlShowDetail" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="supportInterphone">
          <el-input v-model="form.supportInterphone" placeholder="请输入${comment}" />
        </el-form-item>
        <el-form-item label="${comment}" prop="loginLimitIps">
          <el-input v-model="form.loginLimitIps" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="${comment}" prop="lastLoginTime">
          <el-date-picker clearable
            v-model="form.lastLoginTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择${comment}">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listMember, getMember, delMember, addMember, updateMember } from "@/api/system/member";

export default {
  name: "Member",
  dicts: ['sys_normal_disable'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用户表格数据
      memberList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        roleCode: null,
        userName: null,
        password: null,
        title: null,
        parentId: null,
        smsBalance: null,
        rcsBalance: null,
        vacantBalance: null,
        cspBalance: null,
        identBalance: null,
        gsmBalance: null,
        agentId: null,
        changeTime: null,
        serviceRemark: null,
        isEnableHttp: null,
        isEnableCmpp: null,
        isEnableRcs: null,
        isEnableVoids: null,
        isEnableUrlshort: null,
        isEnableFence: null,
        isEnableCsp: null,
        isEnableIdent: null,
        isEnableSmpp: null,
        contactName: null,
        contactPhone: null,
        contactAddress: null,
        securityPhone: null,
        verifiedStep: null,
        lastSendTime: null,
        isShowSaleman: null,
        isLoginCaptcha: null,
        isVerifiedLimit: null,
        isWarnBalance: null,
        warnSilenceDays: null,
        warnMinBalances: null,
        isMarkStar: null,
        hidePhoneMode: null,
        isAutoWhiltelist: null,
        surlDomianIds: null,
        surlShowDetail: null,
        supportInterphone: null,
        status: null,
        recordStatus: null,
        loginLimitIps: null,
        lastLoginTime: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        roleCode: [
          { required: true, message: "角色码不能为空", trigger: "blur" }
        ],
        userName: [
          { required: true, message: "用户名不能为空", trigger: "blur" }
        ],
        password: [
          { required: true, message: "密码不能为空", trigger: "blur" }
        ],
        title: [
          { required: true, message: "昵称不能为空", trigger: "blur" }
        ],
        parentId: [
          { required: true, message: "上级用户不能为空", trigger: "blur" }
        ],
        smsBalance: [
          { required: true, message: "sms余额不能为空", trigger: "blur" }
        ],
        rcsBalance: [
          { required: true, message: "rcs余额不能为空", trigger: "blur" }
        ],
        vacantBalance: [
          { required: true, message: "vacant余额不能为空", trigger: "blur" }
        ],
        cspBalance: [
          { required: true, message: "csp余额不能为空", trigger: "blur" }
        ],
        identBalance: [
          { required: true, message: "ident余额不能为空", trigger: "blur" }
        ],
        gsmBalance: [
          { required: true, message: "gsm余额不能为空", trigger: "blur" }
        ],
        agentId: [
          { required: true, message: "代理id不能为空", trigger: "blur" }
        ],
        createTime: [
          { required: true, message: "创建时间不能为空", trigger: "blur" }
        ],
        changeTime: [
          { required: true, message: "修改时间不能为空", trigger: "blur" }
        ],
        isEnableHttp: [
          { required: true, message: "http授权不能为空", trigger: "change" }
        ],
        isEnableCmpp: [
          { required: true, message: "cmpp授权不能为空", trigger: "blur" }
        ],
        isEnableRcs: [
          { required: true, message: "rcs授权不能为空", trigger: "blur" }
        ],
        isEnableVoids: [
          { required: true, message: "voids授权不能为空", trigger: "blur" }
        ],
        isEnableUrlshort: [
          { required: true, message: "短链授权不能为空", trigger: "blur" }
        ],
        isEnableFence: [
          { required: true, message: "fence授权不能为空", trigger: "blur" }
        ],
        isEnableCsp: [
          { required: true, message: "csp授权不能为空", trigger: "blur" }
        ],
        isEnableIdent: [
          { required: true, message: "ident授权不能为空", trigger: "blur" }
        ],
        isEnableSmpp: [
          { required: true, message: "smpp授权不能为空", trigger: "blur" }
        ],
        verifiedStep: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        isShowSaleman: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        isLoginCaptcha: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        isVerifiedLimit: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        isWarnBalance: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        isMarkStar: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        hidePhoneMode: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        isAutoWhiltelist: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        surlShowDetail: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        supportInterphone: [
          { required: true, message: "$comment不能为空", trigger: "blur" }
        ],
        status: [
          { required: true, message: "$comment不能为空", trigger: "change" }
        ],
        recordStatus: [
          { required: true, message: "$comment不能为空", trigger: "change" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询用户列表 */
    getList() {
      this.loading = true;
      listMember(this.queryParams).then(response => {
        this.memberList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        roleCode: null,
        userName: null,
        password: null,
        title: null,
        parentId: null,
        smsBalance: null,
        rcsBalance: null,
        vacantBalance: null,
        cspBalance: null,
        identBalance: null,
        gsmBalance: null,
        agentId: null,
        createTime: null,
        changeTime: null,
        remark: null,
        serviceRemark: null,
        isEnableHttp: null,
        isEnableCmpp: null,
        isEnableRcs: null,
        isEnableVoids: null,
        isEnableUrlshort: null,
        isEnableFence: null,
        isEnableCsp: null,
        isEnableIdent: null,
        isEnableSmpp: null,
        contactName: null,
        contactPhone: null,
        contactAddress: null,
        securityPhone: null,
        verifiedStep: null,
        lastSendTime: null,
        isShowSaleman: null,
        isLoginCaptcha: null,
        isVerifiedLimit: null,
        isWarnBalance: null,
        warnSilenceDays: null,
        warnMinBalances: null,
        isMarkStar: null,
        hidePhoneMode: null,
        isAutoWhiltelist: null,
        surlDomianIds: null,
        surlShowDetail: null,
        supportInterphone: null,
        status: null,
        recordStatus: null,
        loginLimitIps: null,
        lastLoginTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加用户";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getMember(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改用户";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateMember(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addMember(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除用户编号为"' + ids + '"的数据项？').then(function() {
        return delMember(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/member/export', {
        ...this.queryParams
      }, `member_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
